package main

import (
	"bufio"
	"fmt"
	"net"
	"os"
	"strings"
)

func main() {
	conn, err := net.Dial("tcp", "127.0.0.1:8888")
	if err != nil {
		fmt.Println("error")
		return
	}
	reader := bufio.NewReader(os.Stdin)
	for{
		line, err := reader.ReadString('\n')
		if err != nil {
			fmt.Println("客户端 read error")
		}
		line = strings.Trim(line, " \r\n")
		if line == "exit"{
			fmt.Println("客户端推出")
			return
		}
		n, err := conn.Write([]byte(line + "\n"))
		if err != nil {
			fmt.Println("客户端 conn error")
		}
		fmt.Println("客户端 n : ", n)
	}

}